// =============================================================================
//  Spangles Analyzer
//
//  Copyright(c) 2008
//  See LICENSE.txt for licensing information.
// =============================================================================

package com.google.spangles.domain;

/**
 * (Description)
 * (Any invariants [conditions that are always true] )
 * (Usage instructions, and/or examples)
 * (TODOs, ASSUMPTIONs, etc.)
 * (Known Bugs)
 * (Concurrency strategy - not thread safe or how it's thread safe)
 * 
 * @author Chris
 */
public class Translation
{
   int x;
   
   int y;
   
   public Translation(int x, int y)
   {
      this.x = x;
      this.y = y;
   }
   
   public Translation scale(int r)
   {
      return new Translation(x*r, y*r);
   }
   
   public Location apply(Location source)
   {
      return new Location( source.getX() + x , source.getY() + y);
   }

   /*
    * (non-Javadoc)
    * 
    * @see java.lang.Object#hashCode()
    */
   @Override
   public int hashCode()
   {
      final int prime = 31;
      int result = 1;
      result = prime * result + x;
      result = prime * result + y;
      return result;
   }

   /*
    * (non-Javadoc)
    * 
    * @see java.lang.Object#equals(java.lang.Object)
    */
   @Override
   public boolean equals(Object obj)
   {
      if (this == obj)
         return true;
      if (obj == null)
         return false;
      if (getClass() != obj.getClass())
         return false;
      Translation other = (Translation) obj;
      if (x != other.x)
         return false;
      if (y != other.y)
         return false;
      return true;
   }
}
